package com.example.activiti.common;

import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.Deployment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 流程发布
 * @author zjh
 *
 */
//@Service
@RestController  
@RequestMapping("activitiStart")
public class ActivitiStart {
	//对activiti资源进行操作，比如部署文件，附件
	@Autowired
	private RepositoryService repositoryService;
	
	/**
	 * 流程发布，并非是流程启动
	 * @param processDefinitionKey
	 */
	@GetMapping("repositoryDeploy")
	public void getAllActiviti(String processDefinitionKey) {
//		List<ProcessDefinition> processList = repositoryService
//				.createProcessDefinitionQuery()
//				.processDefinitionKey(processDefinitionKey)
//				.orderByProcessDefinitionVersion()
//				.desc()
//				.list();
//		ProcessDefinition processDefinition = processList.get(0);
//		String processPath = processDefinition.getResourceName();
//		String processPicPath = processDefinition.getDiagramResourceName();
		//流程加载的路径
//		System.out.println("processPath:"+processPath);
		//图片加载的路径
//		System.out.println("processPicPath:"+processPicPath);
		
		//加载流程图
		Deployment deploy = repositoryService.createDeployment()
                .addClasspathResource("processes/ComplateQingjia1.bpmn")
                .addClasspathResource("processes/ComplateQingjia1.png")
                .name("测试一个角色多人审批01")
                .deploy();
        System.out.println("部署ID:"+deploy.getId());
        System.out.println("部署名称"+deploy.getName());
	}
}

